package foo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class MemoryLeak {

	private static final List<Byte[]> mList = new ArrayList<Byte[]>();

	private static final ThreadLocal<List<String>> mapLocal = new ThreadLocal<List<String>>();

	public void run() {
		final List<String> list = mapLocal.get();

		if (null == list) {
			final List<String> name = Arrays.asList("John", "Doe");
			mapLocal.set(name);
			return;
		}

		for (final String n : list) {
			System.out.println("Hello " + n);
		}

		for (int i = 0; i < 10; i++) {
			final Byte[] m = new Byte[10000000];
			mList.add(m);
		}
	}

	public static void main(final String[] args) {
		final MemoryLeak leakGenerator = new MemoryLeak();
		leakGenerator.run();
		leakGenerator.run();
	}
}
